Multiselect List

Hello,

I am new to Doors and DXL and use it now for 3 weeks.

I have to write a GUI for selecting specific Objects in one Module and write theirs attributes to an file.

Object myO
Module m = read ("xYz", false)

DB listShow = null 
DBE headingList = null
DBE selectButton = null

/****************************************************
 Count all Object for StringArray
*****************************************************/

int noOfObj = 0
for myO in current Module do
{
 noOfObj++
}
string headingArray[noOfObj]

/****************************************************
 onclick of selectbutton
*****************************************************/

void on_selectButton(DBE bx)
{
 for s in headingList do{
  string sArray = headingArray[s]
  Buffer buffContain = create()
  buffContain = sArray  
  for myO in current Module do
  { 

   int indexX = 0
   string sNumber = number(myO)
   indexX = contains(buffContain, '~' ,0)

   if (sNumber == sArray[0:indexX])
   {
    /**************************************
     a lot of IfTTT and stream outs
    **************************************/
   }
  } 
 }
}

/****************************************************
 build up the StringArray for multiselectlist
*****************************************************/

int n = 0
for myO in current Module do
{
 string sHeading= myO."Object Heading"

 sHeading= number(myO) "~" sHeading

 headingArray[n++] = sHeading
}
/****************************************************
 build up multiselectlist
*****************************************************/

listShow = create "Liste"
selectButton = button(listShow,"Auswhal",on_selectButton)
headingList = listView(listShow, listViewOptionMultiselect, 300, 10, headingArray)

realize listShow

insertColumn (headingList,0,"List",100,iconAuthenticatingUser)
setSize(listShow,390,500)  

show listShow
close m
1. Can I only use "listViewOptionMultiselect" with string Arrays?

If I could use skiplist I would not need to count all objects in modul.

 

2. Is there a way to get a second column in the list?

 

3. With this 3 for loops it took so long, can you show me a more practical way to do?

 

 


mafo - Thu Mar 30 04:06:57 EDT 2017

Re: Multiselect List
PekkaMakinen - Thu Mar 30 06:38:48 EDT 2017

Wrote as a basis for my future development needs this example for you, hope it helps. Note that I am using a skip list to store the data and using a dummy array (which is not used at all) to create the listView

 

Module m = current

const string dummyArray[] = {}
Skip ObjectSkip = create

DB MainDB = null
DBE ObjectList = null
DBE OKButton = null
DBE CancelButton = null

void DoCancel (DB db)

{
    hide db
    destroy db
    db = null
    
    if (!null ObjectSkip)
       {
         delete ObjectSkip
         ObjectSkip = null  
       }   
}

void DoAction (DB db)

{
    Object o = null
    string ObjectID = ""
    string LastModified = ""
    int NumObj = 0
    Stream OutData = write "c:\\temp\\temp.txt"
    
    OutData << "Selected objects in " name(m) "\n"
    for NumObj in ObjectList do
       {
         ObjectID = getColumnValue(ObjectList, NumObj, 0)   
         LastModified = getColumnValue(ObjectList, NumObj, 1)
         OutData << "--------- " ObjectID " Last modified " LastModified "\n"
         if (find(ObjectSkip, ObjectID, o))
            {
             if (o."Object Text" "" > "") OutData << o."Object Text" "\n\n"
             else OutData << number(o) " " o."Object Heading" "\n\n"
            }
         else   
            {
              OutData << "Object not found in skip - should not happen\n\n"  
            }
       }   
    
    close OutData
    OutData = null   
}    

void FillList ()

{
    Object o = null
    string ObjectID = ""
    string LastModified = ""
    int NumObj = 0
    
    for o in m do
       {
           ObjectID = identifier(o)
           LastModified = o."Last Modified On" ""
           put(ObjectSkip, ObjectID, o)
           // set value for first column
           insert(ObjectList, NumObj, ObjectID, iconNone)
           // set value for second column
           set(ObjectList, NumObj, 1, LastModified)
           NumObj++            
       }   
}    

// MAIN PRROGRAM
if (null m)
  {
    ack "Please run this script in an open module - halting"  
    halt
  }      

MainDB = create "List of objects"
label (MainDB, "Select multiple objects with Ctrl-Click")
left MainDB
ObjectList = listView(MainDB, listViewOptionMultiselect, 300, 10, dummyArray)
OKButton = apply(MainDB,"Output objects",DoAction)
// No default Cancel-button
close(MainDB, false, DoCancel)
// Own Cancel-button
CancelButton = ok(MainDB, "Close", DoCancel)
realize MainDB
//First column
insertColumn (ObjectList, 0,"Object Identifier", 150, iconNone)
//Second column
insertColumn (ObjectList, 1,"Last Modified On", 150, iconNone)
// Fill the listView
FillList
show MainDB

 

Re: Multiselect List
mafo - Thu Mar 30 07:32:32 EDT 2017

Is it faster to iterate though an skiplist as through a modul?

 

How can I measure which is faster.

If I try to measure  I only get Sec, and so both are 3 sec

Date d = null
int currentTime = null
int start = null
d = today
start = intOf(d)

    /*...               
    put your code here
    ...*/

d = today
currentTime = intOf(d)
print  (currentTime - start) "s \n"

 

 

Re: Multiselect List
Mathias Mamsch - Thu Mar 30 08:37:36 EDT 2017

mafo - Thu Mar 30 07:32:32 EDT 2017

Is it faster to iterate though an skiplist as through a modul?

 

How can I measure which is faster.

If I try to measure  I only get Sec, and so both are 3 sec

Date d = null
int currentTime = null
int start = null
d = today
start = intOf(d)

    /*...               
    put your code here
    ...*/

d = today
currentTime = intOf(d)
print  (currentTime - start) "s \n"

 

 

Skip is probably much faster.  You can measure milliseconds using the getTickCount_() perm. If you care about measuring microseconds (e.g. profiling fast operations like skip find), you need to resort to repeating an operation and dividing by the number of milliseconds. For some inspiration see the profiling inside the DXL Standard Library Template: 

https://github.com/domoran/dxlstdlib/blob/master/lib/test/profiler.inc

and for profiling examples: 

https://github.com/domoran/dxlstdlib/tree/master/profiles

Hope that helps, regards, Mathias